package com.example.aop.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Order(2)
@Slf4j
@Aspect
//@Component
public class AspectDemo2 {
    @Before("com.example.aop.aspect.AspectDemo1.pt()")
    public void doBefore(){
        log.info("aspect2 do before...");
    }

    @Around("com.example.aop.aspect.AspectDemo1.pt()")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        log.info("aspect2 do around before...");

        Object object = joinPoint.proceed();

        log.info("aspect2 do around after...");
        return object;
    }

    @After("com.example.aop.aspect.AspectDemo1.pt()")
    public void doAfter(){
        log.info("aspect2 do after...");
    }
}
